package com.matt.foundation.vo.course;

import com.matt.domain.TeachingArea;
import com.matt.domain.course.CoursePlan;
import com.matt.foundation.DO.AdviseDetailDO;
import com.matt.foundation.DO.ChildrenCourseItemDO;
import com.matt.commons.dto.sso.StaffDTO;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/9/11
 * *******************************
 */
@Data
public class WebCoursePlanDetailVo {

    private String coursePlanId;

    private String teachingAreaName;

    private String teacherName;

    private Integer courseType;

    private String courseName;

    private String content;

    private Integer week;

    private String courseTime;

    private String beginTime;

    private String endTime;

    private String typeName;

//    private CoursePlanExtension coursePlanExtension;

    private List<AdviseDetailDO> adviseList;

    private List<String> childrenNames;


    public static WebCoursePlanDetailVo of(CoursePlan coursePlan, TeachingArea teachingArea, StaffDTO staff, /*CoursePlanExtension extension,*/ List<AdviseDetailDO> adviseList, List<ChildrenCourseItemDO> itemList) {
        WebCoursePlanDetailVo vo = new WebCoursePlanDetailVo();
        vo.setCoursePlanId(coursePlan.getId());
        vo.setTeachingAreaName(teachingArea.getName());
        vo.setTeacherName(staff.getRealName());
        vo.setCourseName(coursePlan.getCourseName());
        vo.setCourseType(coursePlan.getCourseType());
        vo.setTypeName(coursePlan.getTypeName());

//        if (coursePlan.getCourseType() == CourseConstant.CourseType.SAT.codeOf()){
//            vo.setWeek(Integer.valueOf(coursePlan.getTypeName()));
//            vo.setContent(extension.getLinkItems());
//        }
//        vo.setCoursePlanExtension(extension);

        vo.setCourseTime(DateUtil.millisToDateTime(coursePlan.getCourseDate().getTime(), "yyyy-MM-dd"));
        vo.setBeginTime(DateUtil.millisToDateTime(coursePlan.getBeginTime().getTime(), "HH:mm"));
        vo.setEndTime(DateUtil.millisToDateTime(coursePlan.getEndTime().getTime(), "HH:mm"));
        vo.setAdviseList(adviseList);
        if (Objects.nonNull(itemList))
            vo.setChildrenNames(itemList.stream().map(o->o.getName()).collect(Collectors.toList()));
        return vo;
    }
}
